
capture cd D:\Dropbox\book_welfare\replication\


import delimited data\goodreads_book_genres_initial.json, delimiter(comma) bindquote(strict) stripquote(yes) clear 

	rename v1 b 
	split b, parse(": ")

	rename b2 book_id 

	rename v2 g 
	split g, parse("{" "," ":")


	rename g3 genre1 
	rename g4 genre2 
	rename g5 genre3 


	replace genre1=subinstr(genre1,"}}","",.)


	keep book_id genre?

	local nums "0 1 2 3 4 5 6 7 8 9"
	foreach  k of local nums { 
		replace genre2="" if substr(genre2,2,1)=="`k'"
		replace genre3="" if substr(genre3,2,1)=="`k'"
		
		}
	
	gen x = real(book_id)
	drop book_id 
	rename x book_id 
	
 save data\book_id_genres.dta, replace 